package com.lhy.common.web.wrapper.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lhy.common.web.entity.ComparatorEnum;
import com.lhy.common.web.entity.DbField;
import com.lhy.common.web.wrapper.AbstractSearchComparator;
import org.springframework.util.StringUtils;

public class GroupBySearchComparator extends AbstractSearchComparator {
    @Override
    public void accept(QueryWrapper queryWrapper, DbField dbField) {
        queryWrapper.groupBy(dbField.getName());
    }


    @Override
    public boolean valid(DbField dbField) {
        return StringUtils.hasText(dbField.getName());
    }

    @Override
    public ComparatorEnum comparatorEnum() {
        return ComparatorEnum.GROUP_BY;
    }
}
